<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        #box{
            width: 500px;
            height: 500px;
            margin-left: 100px;
            background-color: rgba(0,0,0,0.2);
        }
        .bullet{
            width: 100px;
            height: 100px;
            margin-left: 200px;
            background-color: red;
            
        }
    </style>
</head>
<body>
    <div id="box">

    </div>

    <script>
        let oBox = document.getElementById("box");
        let oDiv = document.createElement("div");
        // oDiv.className= "bullet";
        oDiv.classList.add("bullet");
        oDiv.setAttribute("class","bullet")
        oDiv.innerText="xoxoxo";
        oBox.appendChild(oDiv);
        // 获取坐标信息  的对象
        let rect = oDiv.getBoundingClientRect()
        // 
        console.log(rect);

    </script>

</body>
</html>